package com.me.mvc.utils;

import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by roman on 27.02.15.
 */
public class MenuUtils {

    private MenuUtils() {
    }

    static Map<String, List<String>> menu = new HashMap<String,List<String>>();

    static{
        menu.put("main", Arrays.asList("/index", "/clients", "/transactions", "/registration", "bank"));
        menu.put("clients", Arrays.asList("/index", "/clients", "/clients/new", "/clients/new/sdf"));
        menu.put("transactions", Arrays.asList("/index", "/transactions/rest.json", "/transactions/rest.xml"));

    }


    public static String getMenuHtml(String name){
        StringBuilder result = new StringBuilder("");
        List<String> list = menu.get(name);
        if(list!= null && list.size()>0) {
            result.append("\n<ol>");
            for (String link : list) {
                result.append("\n<ol>");
                result.append(MessageFormat.format("\n<a href=\"{0}\">{0}</a>", link));
                result.append("\n</ol>");
            }
            result.append("\n</ol>");
        }
        return result.toString();
    }
}
